<!DOCTYPE html>
<html>

<head lang="en">
    <title>评论游记</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/myStrategyComment.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script>
        $(function () {
            //获取游记id
            var params = getParams();
            //提交按钮添加点击事件
            $("#submitBtn").click(function () {
                var user = JSON.parse(sessionStorage.getItem("user"));
                var commentContent = $("#commentContent").val();
                $.post("/travelComments",
                    {
                        'travelId': params.travelId,
                        'commentContent': commentContent
                    },
                    function (data) {
                        if (data.success) {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '评论成功',
                                autoClose: 1000,
                                position: 'center'  // center: 居中; bottom: 底部
                            });
                            setTimeout(function () {
                                window.history.go(-1);
                            }, 1000);
                        } else {
                            $(document).dialog({
                                type: 'notice',
                                infoText: '网络出问题,请稍候重试',
                                autoClose: 1000,
                                position: 'center'  // center: 居中; bottom: 底部
                            });
                        }
                    })
            });
        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1)">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>游记评论</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<div class="comment">
    <div class="container tag">
        <textarea name="commentContent" id="commentContent" class="form-control" rows="5"
                  placeholder="请填写你对该游记的评论"></textarea>
    </div>
</div>

<div class="operation">
    <button class="btn" onclick="window.history.go(-1)">放弃评论</button>
    <button class="btn" id="submitBtn">提交评论</button>
</div>

</body>
</html>